package chapter_09_composite.classic;

import java.util.ArrayList;
import java.util.List;

/**
 * @author yaochenglong
 * @date 2017/10/19
 * 树枝构件
 * 树枝对象，它的作用是组合树枝节点和叶子节点行程树形结构
 */
public class Branch extends Component {

    //构件容器
    List<Component> componentArrayList = new ArrayList<>();

    //增加节点
    public void add(Component component){
        this.componentArrayList.add(component);
    }

    //删除节点
    public void remove(Component component){
        componentArrayList.remove(component);
    }

    //获得子节点
    public List<Component> getChildren(){
        return this.componentArrayList;
    }
}
